/**
 * @Copyright 2012, Founder Mobile Media Technology（Chongqing） Co., Ltd L.P. All
 *            rights reserved. The information contained herein is confidential
 *            and proprietary to Founder Mobile Media Technology（Chongqing） Co.,
 *            Ltd, and considered a trade secret as defined under civil and
 *            criminal statutes. Founder Mobile Media Technology（Chongqing） Co.,
 *            Ltd shall pursue its civil and criminal remedies in the event of
 *            unauthorized use or misappropriation of its trade secrets. Use of
 *            this information by anyone other than authorized employees of
 *            Founder Mobile Media Technology（Chongqing） Co., Ltd is granted
 *            only under a written non-disclosure agreement, expressly
 *            prescribing the scope and manner of such use.
 */
package com.g2room.map;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.map.MultiKeyMap;
import org.apache.commons.collections.map.MultiValueMap;

/**
 * 
 * 
 * @createTime: May 31, 2013 2:29:36 PM
 * @author: <a href="mailto:gaoxg@FOUNDER.COM.CN">Xuguo Gao</a>
 * @version: 0.1
 * @lastVersion: 0.1
 * @updateTime:
 * @updateAuthor: <a href="mailto:gaoxg@FOUNDER.COM.CN">Xuguo Gao</a>
 * @changesSum:
 * 
 */
public class MultiMap {

	/**
	 * MultiKeyMap，多个key指向一组对象，<br>
	 * add()和remove()的时候跟普通的Map无异，只是可以传入一个key或多个key进行add和remove<br>
	 * 利用MultiMap，可设置不同的key值组，也可在value放置不同类型的对象。
	 *
	 * @auther <a href="mailto:gaoxg@FOUNDER.COM.CN">Gao Xuguo</a>
	 * May 31, 2013 2:37:15 PM
	 */
	public static void multiKeyMap() {
		List<String> list = new ArrayList<String>();
		List<String> valuelist = new ArrayList<String>();
		list.add("123");
		list.add("456");
		list.add("789");
		MultiKeyMap multiMap = new MultiKeyMap();
		multiMap.put("list","numList", list);
		multiMap.put("String", "1", "C/C++");
		multiMap.put("String", "2", "OO");
		multiMap.put("String", "3", "Java");
		multiMap.put("int", 1, 1);
		
		Object obj = multiMap.get("String", "1");
		System.out.println("===="+ obj);
//		System.out.println("Sean's skill set: " + multiMap.get("list"));
//		Iterator itet = ((Collection) multiMap.get("String")).iterator();
//		//"numList"
//		while (itet.hasNext()) {
//			System.out.println("value:" + itet.next().toString());
////			Object obj = itet.next();
////			if (obj instanceof String) {
////				valuelist = (List<String>) obj;
////				for (Object value : valuelist) {
////					System.out.println("obj1:" + value);
////				}
////
////			} else if (obj instanceof String) {
////				System.out.println("value:" + obj.toString());
////			}
//		}
	}
	
	public static void multiValueMap(){
		Date date = new Date();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("1", 1);
		map.put("aa", "a");
		map.put("date", date);
		
		MultiValueMap multiMap = new MultiValueMap();
		multiMap.put("int", 1);
		multiMap.put("int", 2);
		multiMap.put("String", "String01");
		multiMap.put("String", "String02");
		Object o;
		for(Object key : multiMap.keySet()) {
			o = multiMap.get(key);
			if(o instanceof String[]) {
				String[] os = (String[]) o;
				System.out.println(o + "===" + os.length);
			} else if(o instanceof List) {
				List os = (List) o;
				System.out.println(o + "===" + os.size());
			}
		}
	}
}
